
#import "MxPublicNav.h"
@implementation MxPublicNav

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    self.backgroundColor = [UIColor whiteColor];
    self.userInteractionEnabled = YES;
    //返回按钮
    self.backButton = [[ExpandButton alloc] init];
    [self.backButton setImage:[UIImage imageNamed:@"back_login"] forState:UIControlStateNormal];
    [self.backButton addTarget:self action:@selector(tapBack) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.backButton];
    [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(14);
        make.bottom.offset(-8);
        make.height.width.mas_equalTo(28);
    }];
    self.titleLab = [[UILabel alloc] init];
    self.titleLab.textColor = [UIColor colorWithHexString:@"#000000"];
    self.titleLab.font = PFRFont(17);
    self.titleLab.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(100);
        make.right.offset(-100);
        make.bottom.offset(-9);
        make.height.mas_equalTo(25);
    }];
    
    self.rightBtn = [ExpandButton buttonWithType:UIButtonTypeCustom];
    self.rightBtn.hidden = YES;
    [self.rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    self.rightBtn.titleLabel.textAlignment=NSTextAlignmentRight;
    [self.rightBtn addTarget:self action:@selector(tapPush) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_rightBtn];
    [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-15);
        make.bottom.offset(-8);
        make.height.width.mas_equalTo(30);
    }];

    self.line = [[UIView alloc] init];
    self.line.hidden = YES;
    self.line.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"];
    [self addSubview:self.line];
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.offset(0);
        make.height.mas_equalTo(0.5);
    }];
}


//点击返回
- (void)tapBack{
    if (self.delegate && [self.delegate respondsToSelector:@selector(leftTap)]) {
        [self.delegate leftTap];
    }
}

//点击跳转
- (void)tapPush{
    if (self.delegate && [self.delegate respondsToSelector:@selector(rightTap)]) {
        [self.delegate rightTap];
    }
}

@end
